package com.zhuang.linkedlist;

import java.util.LinkedList;
import java.util.ListIterator;

import com.zhuang.linkedlist.linked.DoubleLinkedList;
import com.zhuang.linkedlist.linked.SingleLinkedList;

public class TestLinkedList {

	public static void main(String[] args) {
		test01();
		test02();
		test03();
	}

	public static void test01() {
		LinkedList<Integer> linkedList = new LinkedList<>();
		linkedList.add(1);
		linkedList.add(2);
		linkedList.add(3);
		ListIterator<Integer> iterator = linkedList.listIterator();
		while (iterator.hasNext()) {
			// hashNext 遍历链表长度的次数
			iterator.add(10);
			System.out.println(iterator.next());
		}
	}

	public static void test02() {
		SingleLinkedList<Integer> singleLinkedList = new SingleLinkedList<>();
		singleLinkedList.add(1);
		singleLinkedList.add(2);
		singleLinkedList.add(3);
		singleLinkedList.remove(0);

		System.out.println(singleLinkedList);
	}

	public static void test03() {
		DoubleLinkedList<Integer> doubleLinkedList = new DoubleLinkedList<>();
		doubleLinkedList.add(1);
		doubleLinkedList.add(2);
		doubleLinkedList.add(3);
		doubleLinkedList.remove(0);

		System.out.println(doubleLinkedList);
	}
}
